# 示例1：主窗口及标题
import tkinter as tk

def input1():
    in1 = input("输入值")
    print("输入了：",in1)

win = tk.Tk()  # 根窗口的实例(root窗口)
win.title('Tkinter root window')  # 根窗口标题
# 修改窗体图标
win.iconbitmap('../resources/icon.ico')
# 设置窗口大小
width = 500
height = 300
# 获取屏幕尺寸以计算布局参数，使窗口居屏幕中央
screenwidth = win.winfo_screenwidth()
screenheight = win.winfo_screenheight()
alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth-width)/2, (screenheight-height)/3)
win.geometry(alignstr)

# title
title = tk.Label(win, text='欢迎使用此工具')
title.grid(row=0,column=4)
# 边框样式
border = tk.LabelFrame(win, bd=2, bg="red")
# 第二个Label
theLabel = tk.Label(win, text='网址：', fg='blue')  # label组件及文字内容
# 输入网址
addr = tk.StringVar(value='https://www.pynote.net')
theEntry = tk.Entry(win, fg='black', textvariable=addr)
# 组件位置修改
theEntry.grid(row=1, column=1)
theLabel.grid(row=1, column=0)
# 按钮
but1 = tk.Button()
but1['text'] = '确定'
# but1['common'] = print(theEntry.get())
but1['common'] = print('aaa')
but1.grid(row=1, column=2)
# 设置窗口是否可变长、宽，True：可变，False：不可变
# win.resizable(width=False, height=True)
# theLabel.pack()  # pack()用于自动调节组件的尺寸
# theEntry.pack()
win.mainloop()  # 窗口的主事件循环，必须的